/**
 * 
 */
package io.hilo.example.demo.metric;

import org.springframework.stereotype.Service;

import org.hilo.boot.core.UT;
import org.hilo.boot.core.spring.AsyncRunAfterStart;
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;

/**
 * 
 * @author zollty
 * @since 2020年9月17日
 */
@Service
public class CollectorService implements AsyncRunAfterStart {
    final Counter userCounter;
    
    public CollectorService(MeterRegistry registry) {
        userCounter = registry.counter(
                "app.user.counter.total", "services", "demo");
    }

    @Override
    public void doInit(Object[] args) {
        while (true) {
            UT.Thread.sleepThread(200);
            userCounter.increment(1D);
        }

    }
}
